package com.woniuxy.homepage.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.homepage.core.mapper.CarBrandMapper;
import com.woniuxy.homepage.core.model.CarBrand;
import com.woniuxy.homepage.core.service.CarBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-30
 */
@Api(tags = "车品牌信息接口")
@RestController
@RequestMapping("/carBrand")
public class CarBrandController {

    @Resource
    private CarBrandService carBrandService;

    @Resource
    private CarBrandMapper carBrandMapper;

    /**
     * Description : 查询热门品牌  <br/>
     * ChangeLog : 1. 创建 (2021/7/1 10:02 [Hello Mr. Guo]);
     *
     * @return com.woniuxy.common.CommonResult<com.woniuxy.homepage.core.model.CarBrand>
    */
    @GetMapping("/selectByHot")
    @ApiOperation("获取热门品牌")
    public CommonResult<CarBrand> selecByHot(){
        List<CarBrand> list = this.carBrandService.selectByHot();
        if (list == null){
            return CommonResult.fail("查询热门品牌失败");
        }
        return CommonResult.success(list);
    }



    /**
     * Description : 根据品牌升序查询所有品牌  <br/>
     * ChangeLog : 1. 创建 (2021/7/1 10:52 [Hello Mr. Guo]);
     *
     * @return com.woniuxy.common.CommonResult<com.woniuxy.homepage.core.model.CarBrand>
    */
    @GetMapping("/selectAll")
    @ApiOperation("获取所有车辆品牌")
    public CommonResult<CarBrand> selectAll(){
        List<CarBrand> list = this.carBrandService.selectAll();
        if (list == null){
            return CommonResult.fail("查询所有车辆品牌失败");
        }
        return CommonResult.success(list);
    }


}

